package com.demo.modules.job.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.demo.modules.job.dao.ScheduleJobLogDao;
import com.demo.modules.job.entity.ScheduleJobLogEntity;
import com.demo.modules.job.service.ScheduleJobLogService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("scheduleJobLogService")
public class ScheduleJobLogServiceImpl extends ServiceImpl<ScheduleJobLogDao, ScheduleJobLogEntity>
        implements ScheduleJobLogService {

    @Override
    public List<ScheduleJobLogEntity> queryPage(Map<String, Object> params) {
        String jobId = (String) params.get("jobId");

        List<ScheduleJobLogEntity> scheduleJobLogEntityList = this.list(new LambdaQueryWrapper<ScheduleJobLogEntity>()
                .eq(StringUtils.isNotBlank(jobId), ScheduleJobLogEntity::getJobId, jobId)
                .orderByDesc(ScheduleJobLogEntity::getCreateTime));

        return scheduleJobLogEntityList;
    }
}
